<?php
include_once('_PATH.php');
require_once($_CLASSPATH . '/Broker.interface.php' );

class MysqlBroker /*implements Broker*/ {
	
	private $conn;
	
	private $host;
	private $username;
	private $password;
	private $database; 
	
	function __construct($_host, $_username, $_password, $_database) {
		$this->host     = $_host;
		$this->username = $_username;
		$this->password = $_password;
		$this->database = $_database;
	}
	
	function & getConnection() {
		if ( ! isset( $this->conn ) ) {
			echo 'try';
			$this->conn = mysql_pconnect('localhost', 'root', '');
			echo 'can';
			mysql_select_db($this->database, $this->conn);
			echo 'change';
		}
		echo 'conn' . $this->conn;
		return $this->conn;
	}

	function closeConnection() {
		/*$c = & $this->getConnection();
		return mysql_close( $c );*/
	}

	function & executeQuery( $_query ){
		$c = & $this->getConnection();
		$rs = mysql_query( $_query , $c );
		return $rs;
	}
	
	function execute( $_query ){
		$c = & $this->getConnection();
		return mysql_query( $_query , $c );
	}

	function disposeResultSet( & $_rs ){
		return mysql_free_result( $_rs );
	}
	
	function & fecthAssoc( & $rslt ){
		$r = mysql_fetch_assoc($rslt);
		return $r;
	}
	
}
?>